package com.soft.controller;

import com.soft.pojo.Jianli;
import com.soft.pojo.PageBean;
import com.soft.service.EmpRecordService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ruoxi
 * @create 2021-12-27 14:09
 */
@WebServlet("/showAllResumeCheckByPage")
public class ShowAllResumeCheckByPageServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmpRecordService resumeCheckPgService = new EmpRecordService();
        PageBean<Jianli> resumeCheckPg = new PageBean<>();

        int currentPage = 1;
        String currentPage_ = req.getParameter("currentPage");
        if (currentPage_ != null) {
            currentPage = Integer.parseInt(currentPage_);
        }

        int currentCount = 10;

        resumeCheckPg.setCurrentPage(currentPage);
        resumeCheckPg.setCurrentCount(currentCount);
        resumeCheckPg.setTotalCount(resumeCheckPgService.findEmpRecordCount());
        resumeCheckPg.setTotalPage((int) Math.ceil(resumeCheckPgService.findEmpRecordCount() * 1.0 / currentCount));
        resumeCheckPg.setList(resumeCheckPgService.findEmpRecordCheckByPage((currentPage - 1) * currentCount, currentCount));

        req.setAttribute("resumeCheckPg", resumeCheckPg);
        req.getRequestDispatcher("resumecheck.jsp").forward(req, resp);
    }
}
